package com.etc.controller;

import com.etc.entity.CommentResult;
import com.etc.entity.Owner;
import com.etc.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OwnerController {
    @Autowired
    private OwnerService ownerService;

    @RequestMapping("owner/findAllOwner")
    public CommentResult findAllOwner(@RequestParam(value = "start", required = false) Integer start,
                                      @RequestParam(value = "size", required = false) Integer size)
    {

        List<Owner> list = ownerService.findAllOwner();
        return new CommentResult(200,"success",list);
    }

    @RequestMapping("owner/findById/{id}")
    public CommentResult findById(@PathVariable("id")Integer id)
    {
        Owner result = ownerService.findById(id);
        return new CommentResult(200,"success",result);
    }

    @RequestMapping("owner/findByPark")
    public CommentResult findByPark(@PathVariable("id")Integer id ,@RequestParam(value = "start", required = false) Integer start,
                                      @RequestParam(value = "size", required = false) Integer size)
    {


        List<Owner> list = ownerService.findByPark(id);

        return new CommentResult(200,"success",list);
    }
    @RequestMapping("owner/findByBuilding")
    public CommentResult findByBuilding(@PathVariable("id")Integer id ,@RequestParam(value = "start", required = false) Integer start,
                                    @RequestParam(value = "size", required = false) Integer size)
    {

        List<Owner> list = ownerService.findByBuilding(id);

        return new CommentResult(200,"success",list);
    }

    @RequestMapping("owner/findByRoom/{id}")
    public CommentResult findByRoom(@PathVariable("id")Integer id)
    {
        Owner result = ownerService.findByRoom(id);
        return new CommentResult(200,"success",result);
    }

}
